package com.school.controller.role;

import com.school.service.RoleService;
import com.school.service.impl.RoleServiceImpl;
import com.school.util.RequestJsonUtil;
import com.school.util.ResponseJsonUtil;
import com.school.vo.R;
import com.school.vo.UserRolesParam;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user/role/update")
public class UpdateRoleController extends HttpServlet {
    RoleService roleService = new RoleServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserRolesParam param = RequestJsonUtil.readObject(req, UserRolesParam.class);
        roleService.updateUserRoles(param.getUserid(),param.getRoleids());
        ResponseJsonUtil.write(resp, R.ok());
    }
}
